;;; yisp-helpers.el --- A collect of useful functions convenient controlling.

;; Copyright (C) 2007-6-6 Ducky Yazy <ducky.yazy@gmail.com>

;; Author: Duzy Chan <duzy@duzy.info>
;; Keywords: convenience, lisp

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:
;;
;; This file provides a set of convenient function for helping using Emacs.
;; 

;;; Code:

(require 'yisp-utils)

(defun yisp-toggle-ecb ()
  "Toggles ECB mode."
  (interactive)
  (if ecb-minor-mode
      (ecb-deactivate)
    (ecb-activate)))

(defun yisp-raise-buffer-to-new-frame ()
  "Puts the current buffer into a new frame."
  (interactive)
  (let ((buff (buffer-name (current-buffer))))
    (if buff
        (let ((fram (make-frame)))
          (raise-frame fram)
          (select-frame fram)
          (switch-to-buffer buff)))))

(defun yisp-grep-find (content-pattern file-pattern)
  "Grep-find files, see `grep-find'."
  (interactive
   (list
    (read-from-minibuffer "Regex Content: " (yisp-pick-up-word-at-point))
    (read-from-minibuffer "Regex File Name: " ".*")))
  (unless file-pattern
    (set 'file-pattern ".*"))
  (let ((grep-find-command
         (format "find . -type f -regex \"%s\" -print0 | xargs -0 -e grep -n -e %s"
                 file-pattern content-pattern)))
    (message "Grep Find: %s" grep-find-command)
    (grep-find grep-find-command)))

(provide 'yisp-helpers)
;;; yisp-helpers.el ends here

